window.addEventListener('load', function() {
    var login = document.querySelector('.login');
    var join_in = document.querySelector('#join-in');
    var join_pw = document.querySelector('.join-pw');
    var join_text = document.querySelector('.join-text');
    var join_btn = document.querySelector('.join-btn');
    var replace = document.querySelector('.replace');
    var join_key = document.querySelector('.join-key');
    var rep = 1;
    join_in.addEventListener('contextmenu', function(e) {
        e.preventDefault();
    });
    join_in.addEventListener('selectstart', function(e) {
        e.preventDefault();
    });
    join_pw.addEventListener('contextmenu', function(e) {
        e.preventDefault();
    });
    join_pw.addEventListener('selectstart', function(e) {
        e.preventDefault();
    });
    login.addEventListener('click', function() {
        join_in.style.display = "block";
    });
    join_btn.addEventListener('click', Join);
    replace.addEventListener('click', Replace);

    function Join() {
        if (join_text.value === '100') {
            join_in.style.display = 'none';
        } else if (join_text.value === '1213') {
            join_in.style.display = 'none';
        } else if (join_text.value === '19210723') {
            join_in.style.display = 'none';
        } else if (join_text.value === '万水千山只等闲') {
            join_in.style.display = 'none';
        }
    }

    function Replace() {
        rep++;
        switch (rep) {
            case 1:
                join_key.innerHTML = '问题一：<br>2021年是共产党成立多少年';
                break;
            case 2:
                join_key.innerHTML = '问题二：<br>南京大屠杀死难者国家公祭日是(月日输入提示:0412)';
                break;
            case 3:
                join_key.innerHTML = '问题三：<br>中国共产党第一次全国代表大会举办日期是(年月日输入提示:19491001)';
                break;
            case 4:
                join_key.innerHTML = '问题四：<br>伟大领袖毛泽东所写的七律长征一诗中,红军不怕远征难的下一句是';
                break;
            default:
                join_key.innerHTML = '没有更多问题了,再次点击重复查看之前问题';
        }
        if (rep == 5) {
            rep = 0;
        }
        console.log(rep);
    }
    window.addEventListener('keydown', function(e) {
        if (e.keyCode == 13) {
            join_btn.addEventListener('click', Join());
        }
    });
});